package com.jenkins.test.utils;

import com.jenkins.test.proxy.gov.constant.RequestType;

import java.util.Map;

/**
 * @version V1.0.0
 * @ClassName: {@link HttpsUtil}
 * @Description: HttpsUtil
 * @author: Lanzhou
 * @date: 2022/1/21 17:57
 * @Copyright:2020 All rights reserved.
 */
public class HttpsUtil {

    /**
     * 请求调用类型选择
     *
     * @param type    请求类型
     * @param url     请求路径
     * @param body    请求体
     * @param headers 请求头
     * @return ss
     */
    protected String call(RequestType type, String url, String body, Map<String, String> headers) {
        String result = null;
        switch (type) {
            case GET:
                result = HttpClient.doGet(url, headers);
                break;
            case POST:
                result = HttpClient.doPost(url, body, headers);
                break;
            case PUT:
                result = HttpClient.doPut(url, body, headers);
                break;
            case DELETE:
                result = HttpClient.doDelete(url, headers);
                break;
            default:
                throw new UnsupportedOperationException("当前类型不支持");
        }
        return result;
    }


}
